﻿#pragma once

#include "App/Window.h"

class Input
{
public:
  Input();

  void InitCallbacks(const Ref<Window> &window);

  bool IsKeyJustPressed(int keyCode);
  bool IsKeyPressing(int keyCode);
  bool IsKeyJustReleased(int keyCode);
  bool IsMouseButtonJustPressed(int button);
  bool IsMouseButtonPressing(int button);
  glm::vec2 GetMousePosition();
  glm::vec2 GetMousePositionDelta();

  void SetKeyState(int keyCode, bool state);
  void SetMouseButtonState(int button, bool state);
  void SetMousePosition(const glm::vec2 &pos);
  void SetMousePositionDelta(const glm::vec2 &delta);

  void NextFrame();

private:

  bool m_keys[GLFW_KEY_LAST];
  bool m_keysPrevious[GLFW_KEY_LAST];

  bool m_mouseButtons[GLFW_MOUSE_BUTTON_LAST];
  bool m_mouseButtonsPrevious[GLFW_MOUSE_BUTTON_LAST];

  glm::vec2 m_mousePos;
  glm::vec2 m_mousePosDelta{0.0f};
};